#include <SFML/Graphics.hpp>

#include "level.h"
#include "player.h"

int main(int argc, char **argv)
{
    sf::RenderWindow App(sf::VideoMode(Level::Width*Block::Width, Level::Height*Block::Height, 32), "Recoil");

    Block::LoadTextures();
    Level *level = Level::loadFile("media/levels/tests.pgm");
    Player player(App.GetInput());
	
    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
			else if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape)
				App.Close();
        }

        player.update(App.GetFrameTime());
        level->checkCollisions(player);

		App.Clear();
        App.Draw(*level);
        App.Draw(player);


        App.Display();
    }

    return EXIT_SUCCESS;
}